//
// Created by xili on 2024/8/28 15:00.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution {
public:
    int minimumSize(vector<int> &nums, int maxOperations) {
        int l = 1, r = *max_element(nums.begin(), nums.end());
        int ans = r;
        while (l < r) {
            int m = (l + r) / 2;
            int cnt = 0;
            for (auto &item: nums) {
                cnt += (item - 1) / m;
            }
            if (cnt <= maxOperations) {
                ans = m;
                r = m - 1;
            } else {
                l = m + 1;
            }
        }
        return ans;
    }
};